﻿#include "Frames.h"

namespace LibraryEditor
{

    FrameSet::FrameSet()
    {
    }

    FrameSet::FrameSet(std::unordered_map<MirAction, Frame*> &dictionary) : Dictionary(dictionary)
    {
    }

FrameSet *FrameSet::DefaultMonsterFrameSet = new FrameSet
{
    {MirAction::Standing, new Frame(0, 4, 0, 500)},
    {MirAction::Walking, new Frame(32, 6, 0, 100)},
    {MirAction::Attack1, new Frame(80, 6, 0, 100)},
    {MirAction::Struck, new Frame(128, 2, 0, 200)},
    {MirAction::Die, new Frame(144, 10, 0, 100)},
    {MirAction::Dead, new Frame(153, 1, 9, 1000)},
    {
        MirAction::Revive, new Frame(144, 10, 0, 100) {Reverse = true}
    }
};
FrameSet *FrameSet::DefaultNPCFrameSet = new FrameSet
{
    {MirAction::Standing, new Frame(0, 4, 0, 450)},
    {MirAction::Harvest, new Frame(12, 10, 0, 200)}
};

    int Frame::getStart() const
    {
        return Start;
    }

    void Frame::setStart(int value)
    {
        Start = value;
    }

    int Frame::getCount() const
    {
        return Count;
    }

    void Frame::setCount(int value)
    {
        Count = value;
    }

    int Frame::getSkip() const
    {
        return Skip;
    }

    void Frame::setSkip(int value)
    {
        Skip = value;
    }

    int Frame::getInterval() const
    {
        return Interval;
    }

    void Frame::setInterval(int value)
    {
        Interval = value;
    }

    int Frame::getEffectStart() const
    {
        return EffectStart;
    }

    void Frame::setEffectStart(int value)
    {
        EffectStart = value;
    }

    int Frame::getEffectCount() const
    {
        return EffectCount;
    }

    void Frame::setEffectCount(int value)
    {
        EffectCount = value;
    }

    int Frame::getEffectSkip() const
    {
        return EffectSkip;
    }

    void Frame::setEffectSkip(int value)
    {
        EffectSkip = value;
    }

    int Frame::getEffectInterval() const
    {
        return EffectInterval;
    }

    void Frame::setEffectInterval(int value)
    {
        EffectInterval = value;
    }

    bool Frame::getReverse() const
    {
        return Reverse;
    }

    void Frame::setReverse(bool value)
    {
        Reverse = value;
    }

    bool Frame::getBlend() const
    {
        return Blend;
    }

    void Frame::setBlend(bool value)
    {
        Blend = value;
    }

    int Frame::getOffSet() const
    {
        return getCount() + getSkip();
    }

    Frame::Frame(int start, int count, int skip, int interval, int effectstart, int effectcount, int effectskip, int effectinterval)
    {
        setStart(start);
        setCount(count);
        setSkip(skip);
        setInterval(interval);
        setEffectStart(effectstart);
        setEffectCount(effectcount);
        setEffectSkip(effectskip);
        setEffectInterval(effectinterval);
    }

    Frame::Frame(BinaryReader *reader)
    {
        setStart(reader->ReadInt32());
        setCount(reader->ReadInt32());
        setSkip(reader->ReadInt32());
        setInterval(reader->ReadInt32());
        setEffectStart(reader->ReadInt32());
        setEffectCount(reader->ReadInt32());
        setEffectSkip(reader->ReadInt32());
        setEffectInterval(reader->ReadInt32());
        setReverse(reader->ReadBoolean());
        setBlend(reader->ReadBoolean());
    }

    void Frame::Save(BinaryWriter *writer)
    {
        writer->Write(getStart());
        writer->Write(getCount());
        writer->Write(getSkip());
        writer->Write(getInterval());
        writer->Write(getEffectStart());
        writer->Write(getEffectCount());
        writer->Write(getEffectSkip());
        writer->Write(getEffectInterval());
        writer->Write(getReverse());
        writer->Write(getBlend());
    }
}
